﻿using System;
using System.ComponentModel;

namespace AMEE.MyFusionTestViewModel {

    /// <summary>
    /// The abstract view Model base class.
    /// <para>
    /// Contains a default implemntation of <see cref="IDisposable"/> and <see cref="INotifyPropertyChanged"/>
    /// </para>
    /// </summary>
    [Serializable]
    public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable {

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion


        protected ViewModelBase(){ }


        #region IDisposable Members

        public void Dispose() {
            this.OnDispose();
        }

        /// <summary>
        /// Override this method to handle a call of Dispose.
        /// </summary>
        protected virtual void OnDispose() {
        }

        #endregion

        /// <summary>
        /// Fires PropertyChange Event. You might override this method, if you want additional handling.
        /// </summary>
        /// <param name="propertyName"></param>
        protected virtual void OnPropertyChanged(String propertyName) {
            if(PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        
    }
}

